/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import com.ruipengkj.bean.TSiteGift;
/**
 * 说明：
 * 商品详细公共model
 * @Author：李智深
 * @Date：2012-03-16
 */
public class DGiftDetailModel extends AbstractTableModel {

	private static final long serialVersionUID = 1L;
	private List<TSiteGift> tSiteGift = new ArrayList();
	private Vector<String> columns = new Vector<String>();
	
	private boolean[] bools;
	
	public DGiftDetailModel(){
		columns.add("");
		columns.add("礼品名称");
		columns.add("价值");
		columns.add("积分");
		columns.add("类型");
	}
	
	//获得行数
	@Override
	public int getRowCount(){
		return tSiteGift.size();
	}
	
	//获得列数
	@Override
	public int getColumnCount(){
		return columns.size();
	}
	//获取列名
	@Override
	public String getColumnName(int column){
		return (String)columns.get(column);
	}
	//设置单元格是否可编辑
	@Override
	public boolean isCellEditable(int rowIndex,int columnIndex){
		if (columnIndex == 0 ) 
			return true;
		return false;
	}
//	//获取列对应的类型
//	public Class getColumnClass(int column){
//		return Object.class;
//	}
	//获得单元格的值
	@Override
	public Object getValueAt(int row,int column){
		TSiteGift tdSiteGift= tSiteGift.get(row);
		if(tSiteGift!=null){
			switch (column) {
				case 0:
					return bools[row];
				case 1:
					return tdSiteGift.getName();
				case 2:
					return tdSiteGift.getPrice();
				case 3:
					return tdSiteGift.getPoint();
				case 4:
					return tdSiteGift.getType();
			}
		}
		return null;
	}
	//设置单元格的值
	public void setValueAt(Object aValue,int rowIndex,int columnIndex){
		//TSiteGift tSiteGifts = tSiteGift.get(rowIndex);
		switch (columnIndex) {
			case 0:
				bools[rowIndex] = (Boolean)aValue;
				return;
		}
		super.setValueAt(aValue, rowIndex, columnIndex);
	}
	
	public boolean[] getBools() {
		return bools;
	}
	public List<TSiteGift> getTCommodityList() {
		return tSiteGift;
	}
	
	public void setSiteGiftList(List<TSiteGift> _tSiteGift){
		this.tSiteGift=_tSiteGift;
	}
	public void setRowData(List<TSiteGift> tSiteGiftList) {
		this.tSiteGift = tSiteGiftList;
		for (int i = tSiteGiftList.size() - 1; i >= 0; --i) {
			//tCommodityList.get(i).setNum(1);
		}
		bools = new boolean[tSiteGiftList.size()];
		//rightType = new String[tRightList.size()];
	}
}
